<!DOCTYPE html>
<html>

		<head>
		<meta charset="UTF-8">
		<title>收银员</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.js"></script>
	</head>

	<body>
		<form class="layui-form update_form" action="{:url('index/add_account')}">
			<input type="hidden" name="id" value="{$ad.id}" />
			<div class="layui-form-item">
				<label class="layui-form-label">选择角色{$ad.user_type}</label>
				<div class="layui-input-block" style="float: left; margin-right: 20px; margin-left: 0;">
					<select name="user_type" id="user_type" lay-verify="required" >
						<option value=""></option>
						<option value="2"   {if $ad.user_type==2}selected="selected" {/if}>管理员</option>
						<option value="3" {if $ad.user_type==3}selected="selected" {/if}>财务</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">手机号</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="mobile" value="{$ad.mobile}" readonly="readonly" lay-verify="required" autocomplete="off" class="layui-input"> (作为登录账号)
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">登录密码</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="password" placeholder="登录密码"  autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">姓名</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="user_name"  value="{$ad.user_name}" lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">状态</label>
				<div class="layui-input-block">
					<input type="radio" name="status" {if $ad.status==1}checked="checked" {/if} value="1" title="正常">
					<input type="radio" name="status" {if $ad.status==2}checked="checked" {/if} value="2" title="冻结">
				</div>
			</div>
			<div class="layui-form-item update_btnbox">
				<div class="layui-input-block">
					<button class="layui-btn"  type="button" lay-submit lay-filter="submit_from">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
		<script>
			//提交表单
			function edit_account() {
				$.ajax({
					type: "post",
					url: "{:url('oem/index/edit_account')}",
					data: $('.layui-form').serialize(), //表单数据
					success: function(data) {
						if(data.code == 200) {
							layer.msg('修改成功', {
								icon: 1,
								time: 1500 //2秒关闭（如果不配置，默认是3秒）
							}, function() {
								window.parent.location.reload();
								var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
								parent.layer.close(index);
							});
						} else {
							layer.msg('修改失败！'); //保存成功提示
						}
					},
					error: function(data) {
						var a = data;
					}
				});

			}
			//Demo
			layui.use('form', function() {
				var form = layui.form;
				
				//监听表单提交
				form.on('submit(submit_from)', function(data){
					edit_account();
		  			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
				});
				
			});
		</script>
	</body>

</html>